<?php
$test = strtolower($_FILES["file"]["type"]);
echo $test;
if ((($_FILES["file"]["type"] == "image/gif")
        || ($_FILES["file"]["type"] == "image/jpeg")
        || ($_FILES["file"]["type"] == "image/png"))
    && ($_FILES["file"]["size"] < 2000000))
{
    if ($_FILES["file"]["error"] > 0)
    {
        echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
    else
    {
        $md5file = md5_file($_FILES["file"]["tmp_name"]);
?>
        <div style="text-align: center;">
        <span>http://localhost/upload/<?php echo $md5file; ?></span>
        <p><img src="http://localhost/upload/<?php echo $md5file; ?>"></p>
        </div>
 <?php
        move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $md5file);
    }
}else
{
    ?>
    <div style="text-align: center;">
        <span>无效文件</span>
    </div>
    <?php
}
?>

